<%--
 *  File:    ZylOrgpdGroup.jsp
 *  @Author: Hilldao
 *  Date:    2012/08/13
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>     
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>


<%
  //init param
  Category cat = Category.getInstance("jsp.ZylOrgpdGroup");
   
  String strModuleName = "DMS";
  String strTableName = "ovresoninfo";
  Integer sourceorgid = new Integer(-1);
  String contextPath = request.getContextPath();
%>



<%
  //get userinfo
  HashMap CurUserInfo = (HashMap)session.getAttribute("userinfo");

%>
<% //--------------------------------------  include files list --%>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>
<%@ include file="/inc/CatchError.inc" %>

<html>
<head>
<title></title>
<PageFlow:CheckPageFlow pageName="p_zylorgpdgroup"/>
<%
  Integer datacategory = (Integer) pageContext.getAttribute("datacategory");
%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath%>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>
<script language="JavaScript" src="<%=contextPath%>/js/FuncLib.js"></script>
<%@ include file="../../inc/SummaryDivision.inc" %>
<script>

function page_add()
{
	if(!checkForm(document.resoninfoform))
 		return;
	document.resoninfoform.actionname.value = "add";
	isRunning = true;
    document.resoninfoform.target = "_self";
	document.resoninfoform.submit();
}

function page_delete() {

  if (checkedNumber(document.resoninfoform.orgpdgroupids) == 0) {
	alert("<%= message.getMessageDesc("PLEASE_SELECT") %>");
    return;
  }
  
  document.resoninfoform.actionname.value = "delete";
	isRunning = true;
    document.resoninfoform.target = "_self";
	document.resoninfoform.submit();
}

function checkedNumber(ids) {
  if(ids == null)
    return 0;
  if(ids.length == null) {
    if(ids.checked)
      return 1;
    else
      return 0;
  }
  var count = 0;
  for(var i = 0; i < ids.length; i ++) {
    if(ids[i].checked)
      count ++;
  }
  return count;
}

function set_orgNameByPopWindow(id,code,name){
	document.resoninfoform.prodgroupid.value=id;
	document.resoninfoform.productgroupname.value=name;
}

function popprodgroup()
{
  window.open("<%=contextPath%>/masterdata/upm/ProductbrandPopWindow.jsp?<%= OvalTools.randomURL() %>&datacategory=<%= datacategory %>", "newwindow", "height=400, width=600,top=120,left=120,toolbar=no, menubar=no, scrollbars=yes, resizable=no, location=no, status=yes");
}
</script>
<% 
  Vector totalsummary = (Vector)pageContext.getAttribute("totalsummary");
  if(totalsummary == null)
  {
    totalsummary = new Vector();
  }
  
  String strDisplayFlag="";
  if(request.getParameter("displayflag")!=null)
  {
    strDisplayFlag=request.getParameter("displayflag");
  }
%>
</head>
<body>
<table width="100%" cellspacing="0">
 <form name="resoninfoform" method="post" action="<%=contextPath%>/Dispatcher" >
   <input type="hidden" name="pagename" value="p_zylorgpdgroup">
	 <input type="hidden" name="actionname">
	 <input type="hidden" name="languagecode" value="<%= strLanguageCode %>">
     <custom:hidden property="orgid"/>
     <custom:hidden property="datacategory"/>

<table width="100%" cellspacing="0">
  <% //--------------------------------------  page location --%>
	<%@ include file="../../inc/PageLocation.inc" %>
</table>
<table width="100%" cellspacing="0" border="0" cellpadding="0">
  <tr>
    <td class="summary_top"></td>
  </tr>

  <tr>
    <td>
      <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
          <%if(!(strDisplayFlag).equals("view")){%>
          <tr>
            <td colspan="3" class="td_right">
              <a onclick="page_add();"><custom:button type="2" label="L_Add" imgsrc="add_btn.gif" border="0"/></a>
              <a onclick="page_delete();"><custom:button type="2" label="L_Delete" imgsrc="delete_btn.gif" border="0"/></a>
            </td>
          </tr>
          <%}%>
          <tr class="deepblue-left" >
            <td class="title_center">&nbsp;</td>
            <td class="title_center"><%= label.getLabelName("L_ProductGroup")%><span class="red">*</span></td>
            <td class="title_center"><%= label.getLabelName("L_Customer")+label.getLabelName("L_Property") %><span class="red">*</span></td>
          </tr>

		  <%
             int j = 0;
             String strClassType = new String();
          %>
          <logic:iterate id="reasoninfo" collection="<%= totalsummary %>">

         <%
            HashMap resoninfoMap = (HashMap)pageContext.getAttribute("reasoninfo");

            if(j%2 == 1){
              strClassType = "td-listrom";
            }else{
              strClassType = "";
            }
            j++;
          %>

           <tr onmouseover="this.className='tr-over'" onmouseout="this.className='<%=JspHelper.filterNull(strClassType)%>'" class="<%=JspHelper.filterNull(strClassType)%>">
            <td width="5%">
              <%if(!(strDisplayFlag).equals("view")){%>
                <input type="checkbox" name="orgpdgroupids" value="<%=JspHelper.filterNull( resoninfoMap.get("orgpdgroupid"))%>" class="checkbox">
              <%}%>
              &nbsp;
            </td>
            <td><custom:write property="productgroupname" name="reasoninfo"/>&nbsp;</td>
            <%if (datacategory.intValue() == 10){%>
              <td><custom:write property="grade" name="reasoninfo" dictType="DealersLevel"/></td>
            <%}%>
            <%if (datacategory.intValue() == 16){%>
              <td><custom:write property="grade" name="reasoninfo" dictType="PuYaoBusinessLevel"/></td>
            <%}%>
            <%if (datacategory.intValue() == 12){%>
              <td><custom:write property="grade" name="reasoninfo" dictType="PharmacyLevel"/></td>
            <%}%>
            <%if (datacategory.intValue() == 11){%>
              <td><custom:write property="grade" name="reasoninfo" dictType="YLHospitalLevel1"/></td>
            <%}%>
            <%if (datacategory.intValue() == 18){%>
              <td><custom:write property="grade" name="reasoninfo" dictType="ZylSalesLevel"/></td>
            <%}%>
            <%if (datacategory.intValue() == 19){%>
              <td><custom:write property="grade" name="reasoninfo" dictType="ZylPotentialLevel"/></td>
            <%}%>
          </tr>
          </logic:iterate>
          
 		  <%if(!(strDisplayFlag).equals("view")){%>
          <tr>
          	 <td>&nbsp;</td>
			<td>
                <custom:text property="productgroupname" command="notnull" label="L_ProductGroup" readonly="true"/>
           		<a onclick='javascript:popprodgroup();'><custom:button type="3" label="L_Asterisk" imgsrc="flash.gif" border="0"/></a>
                <custom:hidden property="prodgroupid" />
            </td>
           <td> 
           <%if (datacategory.intValue() == 10){%>
             <custom:selectdic dictType="DealersLevel" property="grade" defaultValue="------" defaultValueCost=" " command="notnull" label="L_Property"/>
           <%}%>
           <%if (datacategory.intValue() == 16){%>
             <custom:selectdic dictType="PuYaoBusinessLevel" property="grade" defaultValue="------" defaultValueCost=" " command="notnull" label="L_Property"/>
           <%}%>
           <%if (datacategory.intValue() == 12){%>
             <custom:selectdic dictType="PharmacyLevel" property="grade" valueCriteria="1,2,3" defaultValue="------" defaultValueCost=" " command="notnull" label="L_Property"/>
           <%}%>
           <%if (datacategory.intValue() == 11){%>
             <custom:selectdic dictType="YLHospitalLevel1" property="grade" defaultValue="------" defaultValueCost=" " command="notnull" label="L_Property"/>
           <%}%>
           <%if (datacategory.intValue() == 18){%>
             <custom:selectdic dictType="ZylSalesLevel" property="grade" defaultValue="------" defaultValueCost=" " command="notnull" label="L_Property"/>
           <%}%>
           <%if (datacategory.intValue() == 19){%>
             <custom:selectdic dictType="ZylPotentialLevel" property="grade" defaultValue="------" defaultValueCost=" " command="notnull" label="L_Property"/>
           <%}%>
           </td>
          </tr>
		  <%}%>
      </table>
      <table width="100%" cellspacing="0" cellpadding="0">
        <tr>
          <td class="summary_top"></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</form>
</table>
</body>
</html>